﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js" type="text/javascript"></script>
        <title></title>
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css" />
        <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css" />
        <script language="javascript" type="text/javascript">
            //保存成功的提示信息
            function showResult() {
                showResultDiv(true);
                window.setTimeout("showResultDiv(false);", 3000);
            }
            function showResultDiv(flag) {
                var divResult = document.getElementById("save_result_info");
                if (flag)
                    divResult.style.display = "block";
                else
                    divResult.style.display = "none";
            }
        </script>
        <script src="../js/module.js"></script>

    </head>
    <body>
        <!--Logo区域开始-->
        <div id="header">
            <img src="../images/logo.png" alt="logo" class="left"/>
            <a href="#">[退出]</a>            
        </div>
        <!--Logo区域结束-->
        <!--导航区域开始-->
        <div id="navi">
            <ul id="menu">
                <li><a href="../index.html" class="index_off"></a></li>
                <li><a href="../user/user_info.html" class="information_off"></a></li>
                <li><a href="../user/user_modi_pwd.html" class="password_off"></a></li>
            </ul>
        </div>
        <!--导航区域结束-->
        <!--主要区域开始-->
        <div id="main">
            <!--保存操作的提示信息-->
            <div id="save_result_info" class="save_fail">资费修改失败！数据并发错误。</div>
            <form action="" method="" class="main_form">
                <!--必填项-->
                <div class="text_info clearfix"><span>业务账号ID：</span></div>
                <div class="input_info">
                    <input type="text" id="input1" value="" readonly class="readonly" />
                </div>
                <div class="text_info clearfix"><span>OS 账号：</span></div>
                <div class="input_info">
                    <input type="text" id="input2" value="" readonly class="readonly" />
                </div>
                <div class="text_info clearfix"><span>服务器 IP：</span></div>
                <div class="input_info">
                    <input type="text" id="input3" value=" " readonly class="readonly" />
                </div>
                <div class="text_info clearfix"><span>资费类型：</span></div>
                <div class="input_info">
                    <select  id="name" name="name">
                        <!--<option>包 20 小时</option>-->
                        <!--<option>包 40 小时</option>-->
                        <!--<option>包 60 小时</option>-->
                        <!--<option>包月</option>-->
                    </select>
                    <div class="validate_msg_long">请修改资费类型，或者取消修改操作。</div>                      
                </div>
                <!--操作按钮-->
                <div class="button_info clearfix">
                    <input type="button" id="but1" value="保存" class="btn_save"  />
                    <input type="button" value="取消" class="btn_save" />
                </div>

                
                <p>业务说明：<br />
                1、修改资费后，点击保存，并未真正修改数据库中的数据；<br />
                2、提交操作到消息队列；<br />
                3、每月月底由程序自动完成业务所关联的资费；</p>
                
            </form>  
        </div>
        <!--主要区域结束-->
        <div id="footer">
            <span>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</span>
            <br />
            <span>版权所有(C)云科技有限公司 </span>
        </div>
    </body>
<script type="text/javascript">
    $(function () {
        var urlParm = decodeURI(window.location.href.split("?")[1]);
        var serviceId = urlParm.split("serviceId=")[1].split("&")[0];
        var osUsername = urlParm.split("serviceId=")[1].split("&")[1].split("=")[1];
       //  var osUsername =urlParm.split("osUsername")[1].split("&")[1].split("=")[0];
        var unixHost = urlParm.split("osUsername")[1].split("&")[1].split("=")[1];
     $('#input1').attr('value',serviceId);
     $('#input2').attr('value',osUsername);
     console.log(osUsername);
     $('#input3').attr('value',unixHost);
     console.log(unixHost);



        //查询遍历资费类型
        $.ajax({
            type: "GET",
            url: "/kobe/service/findCostName",
            dataType: "json",
            success: function (resp) {

                var name = $('#name');
                for (var item of resp) {
                    var costName = $('<option></option>').text(item.name).val(item.costId);
                    name.append(costName);
                }
            }
        });
        $('#but1').click(function () {
             var costId = $('#name').val();
            console.log(costId);
            console.log(serviceId);
            // $.ajax({
            //     url:"/kobe/service/updateName",
            //     type:"POST",
            //     data:{
            //         "costId":costId,
            //         "serviceId":serviceId
            //     }
            //     ,
            //     success: function (resp) {
            //         if (resp > 0) {
            //             location.href = "/kobe/service/service_list.html";
            //         }
            //     }
            // })
            var data = {
                "costId":costId,
                "serviceId":serviceId
            }
            var setting = {
                url:"/kobe/service/updateName",
                type:"POST",
                headers:{
                    "Content-Type": 'application/json'
                },
                data: JSON.stringify(data)
            }
            $.ajax(setting).done(function (resp) {

                location.href = "/kobe/service/service_list.html";

            })
        })

    })

</script>
</html>
